var database = require('../../../../data/data.js')
Page({

  data: {
    loading: true
  },

  onLoad: function (options) {
    var count = 0;
    var all = 2;
    wx.showLoading({
      title: '资源加载中',
      mask: true
    })
    var that = this;
    var id = options.id;
    var userid = options.userid;
    var userId = "";
    var flag = true;
    var index = 0;
    var comments = [];
    if (userid != null) {
      flag = false;
      userId = userid;
    } else {
      userId = database.userId
    }
    this.setData({
      teamid: id,
      flag: flag
    })
    wx.request({
      url: database.url1 + '/api/V2/softball/get_softball',
      method: "POST",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        accessToken: database.accessToken,
        userId: userId,
        softballId: id
      },
      success(res) {
        count++;
        if (count == all) {
          wx.hideLoading();
          that.setData({
            loading: false
          })
        }
        that.setData({
          teamDetail: res.data.data
        })
      }
    });
    wx.request({
      url: database.url + '/project/getMyComment.action',
      method: "POST",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        teamid: id,
      },
      success(res) {
        console.log(res)
        count++;
        if (count == all) {
          wx.hideLoading();
          that.setData({
            loading: false
          })
        }
        var commentData = res.data;
        that.setData({
          comments: res.data,
          commentsLength: commentData.length
        })
      }
    })
  },
})